<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>我秀地图</title>
    <meta charset="utf-8"/>
    <link  href=""  rel="shortcut icon" type="image/x-icon" />
    <link href="../css/imap-gl.css" rel="stylesheet"/>
    <script src="../js/imap-gl.js"></script>
    <style>
        html, body {
            padding: 0;
            margin: 0;
            height: 100%;
            overflow: hidden;
        }

        #map {
            height: 100%;
            z-index: 0;
        }

    </style>
</head>
<body>
<div id='map'></div>
<script>
    //设置msp_server为本地msp服务IP地址
    var map = new imapgl.Map({
        container: 'map',
        center: [116.38504400000001,39.890383],
        zoom: 3,
        minZoom: 3,
        hash: true,
        maxZoom: 20,
        localIdeographFontFamily: "微软雅黑, 'Microsoft Sans Serif', sans-serif,宋体",
        antialias: false,
        style: "../styles/v1/light-v10-gcj02.json"
    });
    map.on('load', function () {
        // Add an image to use as a custom marker
        map.loadImage(
            'http://172.192.100.51:50001/images/monkey.png',
            function (error, image) {
                if (error) throw error;
                map.addImage('custom-marker', image);
                // Add a GeoJSON source with 2 points
                map.addSource('points', {
                    'type': 'geojson',
                    'data': {
                        'type': 'FeatureCollection',
                        'features': [
                            {
                                // feature 1
                                'type': 'Feature',
                                'geometry': {
                                    'type': 'Point',
                                    'coordinates': [
                                        116.38504400000001,39.890383
                                    ]
                                },
                                'properties': {
                                    'title': '江苏'
                                }
                            },
                            {
                                // feature 2
                                'type': 'Feature',
                                'geometry': {
                                    'type': 'Point',
                                    'coordinates': [116.398262,39.878136000000005]
                                },
                                'properties': {
                                    'title': '北京'
                                }
                            }
                        ]
                    }
                });

                // Add a symbol layer
                map.addLayer({
                    'id': 'points',
                    'type': 'symbol',
                    'source': 'points',
                    'layout': {
                        'icon-image': 'custom-marker',
                        // get the title name from the source's "title" property
                        'text-field': ['get', 'title'],
                        'text-font': [
                            "Microsoft YaHei"
                        ],
                        'text-offset': [0, 0],
                        'text-anchor': 'top'
                    }
                });
            }
        );
    });
</script>
</body>
</html>
